<template>
  <el-drawer
    title="文件信息"
    :visible.sync="informationData.drawer"
    direction="rtl"
    size="40%"
  >
    <!-- :before-close="handleClose" -->
    <el-form class="my-form">
      <el-row>
        <el-col :span="24">
          <el-form-item
            label="文件名称"
          >{{ documentResponse.documentName }}
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item
            label="编号"
          >{{ documentResponse.documentCode }}
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="版本号">
            {{ documentResponse.version }}</el-form-item></el-col>

        <!-- <el-col :span="24">
          <el-form-item label="受控状态"
            >{{ dataList.documentName }}
          </el-form-item></el-col
        > -->
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item
            v-if="personnel('newApply', 'newApplyData')"
            label="起草人"
          >{{ newApplyData.handleUserName }}
          </el-form-item></el-col>
        <el-col :span="8">
          <el-form-item label="日期">
            {{ $moment(newApplyData.updateTime).format('YYYY-MM-DD') }}</el-form-item></el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item v-if="personnel('audit', 'auditData')" label="审核人">
            {{ auditData.handleUserName }}</el-form-item></el-col>
        <el-col :span="8">
          <el-form-item label="日期">
            {{ $moment(auditData.updateTime).format('YYYY-MM-DD') }}
          </el-form-item></el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item
            v-if="personnel('approve', 'approveData')"
            label="批准人"
          >
            {{ approveData.handleUserName }}
          </el-form-item></el-col>
        <el-col :span="8">
          <el-form-item
            label="日期"
          >{{ $moment(approveData.updateTime).format('YYYY-MM-DD') }}
          </el-form-item></el-col>
      </el-row>
      <el-row>
        <el-col :span="18">
          <el-form-item
            label="生效日期"
          >{{ row.effectDate }}
          </el-form-item></el-col>
      </el-row>
      <el-row>
        <el-col :span="18">
          <el-form-item label="发放部门、人员">
            <el-tag v-for="item in nameData" :key="item.id">
              {{ item.label }}
            </el-tag>
          </el-form-item></el-col>
      </el-row>
    </el-form>
  </el-drawer>
</template>

<script>
import { getDocumentInfoOfRelease } from '@/api/xd/documentFlow'
export default {
  props: ['informationData'],
  data() {
    return {
      dataList: {},
      nameData: [],
      trainResponses: '',
      documentResponse: '',
      newApplyData: '',
      auditData: '',
      approveData: '',
      row: ''
    }
  },
  watch: {
    informationData(data) {
      this.row = data.row
      this.getDocumentInfoOfRelease(data.row.documentFlowId)
    }
  },
  mounted() {},
  methods: {
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then((_) => {
          done()
        })
        .catch((_) => {})
    },
    getDocumentInfoOfRelease(id) {
      getDocumentInfoOfRelease({
        documentFlowId: id
      }).then((res) => {
        this.dataList = res.data.documentFlowHandleResponses
        this.documentResponse = res.data.documentResponse
        this.nameData = [
          ...res.data.documentReleaseStatusResponse.groupResponses,
          ...res.data.documentReleaseStatusResponse.userResponses
        ]
        if (res.data.trainResponses.length > 0) {
          this.trainResponses = res.data.trainResponses[0]
        }
      })
    },
    // 基本信息人员

    personnel(node, res) {
      var result = false
      if (this.dataList.length > 0) {
        this.dataList.map((item) => {
          if (item.phase == node) {
            result = true
            this[res] = item
          }
        })
        return result
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.my-form {
  padding: 20px;
}
</style>>
